home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 19 / develop 19 code / GX Bitmaps / Bitmap_PrepareToAnimate.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-21  |  2.2 KB  |  81 lines  |  [TEXT/KAHL]

  1. /*
  2. ••••••••••••••••••••••••
  3.     Bitmap_PrepareToAnimate.c
  4.     David Surovell
  5.  
  6.     Animating Bitmaps in GX: Under QuickDraw, blitting raster images into animating palette
  7.     entries is achieved by setting the source bitmap’s color table flags appropriately.
  8.     Under QuickDraw GX, the process is a bit more difficult, and involves cloning
  9.     references to the destination viewDevice colorSet and colorProfile and inserting
  10.     those references into the bitmap shape before drawing.
  11. ••••••••••••••••••••••••
  12. */
  13.  
  14.  
  15. #include <Types.h>
  16. #include <Memory.h>
  17.  
  18. #include "graphics types.h"
  19. #include "graphics errors.h"
  20. #include "graphics routines.h"
  21.  
  22. #include "graphics libraries.h"
  23.  
  24.  
  25.  
  26. Boolean AttachShapeToDevice(
  27.     gxViewDevice    targetDevice,
  28.     gxShape        targetShape );
  29.  
  30.  
  31. Boolean AttachShapeToDevice(
  32.     gxViewDevice    targetDevice,
  33.     gxShape        targetShape )
  34. {
  35. gxBitmap            bmInfo;
  36. gxColorSet        targetDevCSet, targetDevCSetClone;
  37. gxColorProfile        targetDevProfile, targetDevProfileClone;
  38. gxInk            targetInk;
  39. gxTransferMode    targetTransferMode;
  40.  
  41.     if ((targetDevice == nil) || (targetShape == nil))
  42.         return false;
  43.  
  44.     if (GXGetShapeType( targetShape ) != gxBitmapType)
  45.         return false;
  46.  
  47.     /* obtain references to the target viewDevice’s color set and profile */
  48.     targetDevCSet = GetViewDeviceColorSet( targetDevice );
  49.     targetDevProfile = GetViewDeviceColorProfile( targetDevice );
  50.     if (targetDevCSet == nil)
  51.         return false;
  52.  
  53.     /* clone the references */
  54.     targetDevCSetClone = GXCloneColorSet( targetDevCSet );
  55.     targetDevProfileClone = nil;
  56.     if (targetDevProfile != nil)
  57.         targetDevProfileClone = GXCloneColorProfile( targetDevProfile );
  58.  
  59.     /* assign the clones into the shape and its ink’s transfer mode */
  60.     targetInk = GXGetShapeInk( targetShape );
  61.     if (targetInk != nil)
  62.     {
  63.         // •••NOTE: this only works if the xferMode is copyMode
  64.  
  65.         (void)GXGetInkTransfer( targetInk, &targetTransferMode );
  66.         targetTransferMode.set = targetDevCSetClone;
  67.         targetTransferMode.profile = targetDevProfileClone;
  68.         GXSetInkTransfer( targetInk, &targetTransferMode );
  69.     }
  70.  
  71.     /* assign the clones into the shape and its ink’s transfer mode */
  72.     GXGetBitmap( targetShape, &bmInfo, nil );
  73.     bmInfo.set = targetDevCSet;
  74.     bmInfo.profile = targetDevProfile;
  75.     GXSetBitmap( targetShape, &bmInfo, nil );
  76.  
  77.     return true;
  78. }
  79.  
  80.  
  81.